﻿#pragma once

#include <spdlog/spdlog.h>
#include <spdlog/sinks/stdout_color_sinks.h>
#include <spdlog/sinks/basic_file_sink.h>

#ifdef BUILD_DLL
#define LOGGER_API __declspec(dllimport)
#else
#define LOGGER_API __declspec(dllexport)
#endif

// 前置声明单例接口
//class CORE_API Logger;

// EXE实现的导出函数：获取单例实例（全局唯一）
// extern "C" CORE_API Logger *GetInstance();

class CORE_API Logger
{
public:
  // 禁止拷贝和移动
  Logger(const Logger &) = delete;
  Logger &operator=(const Logger &) = delete;
  Logger(Logger &&) = delete;
  Logger &operator=(Logger &&) = delete;

  Ref<spdlog::logger> logger{nullptr};

  static Logger &GetInstance();

private:
  Logger();

  Ref<spdlog::sinks::stdout_color_sink_mt> m_sinkConsole{nullptr};
  Ref<spdlog::sinks::basic_file_sink_mt> m_sinkFile{nullptr};

  // friend CORE_API Logger *GetInstance();
};



#ifdef ENABLE_LOG
#define LOG_TRACE(...) Logger::GetInstance().logger->trace(__VA_ARGS__)
#define LOG_INFO(...) Logger::GetInstance().logger->info(__VA_ARGS__)
#define LOG_WARN(...) Logger::GetInstance().logger->warn(__VA_ARGS__)
#define LOG_ERROR(...) Logger::GetInstance().logger->error(__VA_ARGS__)
#else
#define LOG_TRACE(...)
#define LOG_INFO(...)
#define LOG_WARN(...)
#define LOG_ERROR(...)
#endif
